﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Pulsar
{
    public partial class EditScenario : Form
    {
        PulsarScenario scenario;

        public EditScenario(ref PulsarScenario scenario)
        {
            InitializeComponent();
            this.CenterToScreen();

            this.scenario = scenario;
        }

        private void EditScenario_Load(object sender, EventArgs e)
        {
            numericUpDown1.Value = scenario.SingleStimulusTimeDuration;
            numericUpDown2.Value = scenario.PauseBetweenStimuliDuration;
            numericUpDown4.Value = scenario.BetweenStimulusCode;
            

            if (scenario.Events.Length>0)
            {
                numericUpDown3.Value = scenario.Events[0].StimulusStartCode;
                numericUpDown5.Value = scenario.Events[0].StimulusEndCode;
                numericUpDown6.Value = scenario.Events[0].Repetions;
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            scenario.SingleStimulusTimeDuration = (int)numericUpDown1.Value;
            scenario.PauseBetweenStimuliDuration = (int)numericUpDown2.Value;
            scenario.BetweenStimulusCode = (int)numericUpDown4.Value;


            foreach(PulsarEvent pevent in scenario.Events)
            {
                pevent.StimulusStartCode = (short)numericUpDown3.Value;
                pevent.StimulusEndCode = (short)numericUpDown5.Value;
                pevent.Repetions = (int)numericUpDown6.Value;
            }

            this.Close();
        }
    }
}
